package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YqRiskCheck;
import com.ruoyi.system.service.IYqRiskCheckService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 疫情风险排查Controller
 * 
 * @author ruoyi
 * @date 2022-03-18
 */
@Controller
@RequestMapping("/system/yqriskcheck")
public class YqRiskCheckController extends BaseController
{
    private String prefix = "system/yqriskcheck";

    @Autowired
    private IYqRiskCheckService yqRiskCheckService;

    @RequiresPermissions("system:yqriskcheck:view")
    @GetMapping()
    public String yqriskcheck()
    {
        return prefix + "/yqriskcheck";
    }

    /**
     * 查询疫情风险排查列表
     */
    @RequiresPermissions("system:yqriskcheck:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YqRiskCheck yqRiskCheck)
    {
        startPage();
        List<YqRiskCheck> list = yqRiskCheckService.selectYqRiskCheckList(yqRiskCheck);
        return getDataTable(list);
    }

    /**
     * 导出疫情风险排查列表
     */
    @RequiresPermissions("system:yqriskcheck:export")
    @Log(title = "疫情风险排查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YqRiskCheck yqRiskCheck)
    {
        List<YqRiskCheck> list = yqRiskCheckService.selectYqRiskCheckList(yqRiskCheck);
        ExcelUtil<YqRiskCheck> util = new ExcelUtil<YqRiskCheck>(YqRiskCheck.class);
        return util.exportExcel(list, "疫情风险排查数据");
    }

    /**
     * 新增疫情风险排查
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存疫情风险排查
     */
    @RequiresPermissions("system:yqriskcheck:add")
    @Log(title = "疫情风险排查", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YqRiskCheck yqRiskCheck)
    {
        return toAjax(yqRiskCheckService.insertYqRiskCheck(yqRiskCheck));
    }

    /**
     * 修改疫情风险排查
     */
    @RequiresPermissions("system:yqriskcheck:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        YqRiskCheck yqRiskCheck = yqRiskCheckService.selectYqRiskCheckById(id);
        mmap.put("yqRiskCheck", yqRiskCheck);
        return prefix + "/edit";
    }

    /**
     * 修改保存疫情风险排查
     */
    @RequiresPermissions("system:yqriskcheck:edit")
    @Log(title = "疫情风险排查", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YqRiskCheck yqRiskCheck)
    {
        return toAjax(yqRiskCheckService.updateYqRiskCheck(yqRiskCheck));
    }

    /**
     * 删除疫情风险排查
     */
    @RequiresPermissions("system:yqriskcheck:remove")
    @Log(title = "疫情风险排查", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yqRiskCheckService.deleteYqRiskCheckByIds(ids));
    }
}
